from django.db import models


# Create your models here.

# 菜品模型
class MenuItem(models.Model):
    item_id = models.AutoField(primary_key=True)  # 菜品ID
    name = models.CharField('菜名', max_length=20)
    price = models.DecimalField('价格', max_digits=10, decimal_places=2)
    rating = models.DecimalField('评分', max_digits=3, decimal_places=2)
    description = models.CharField('说明', max_length=100)
    category = models.CharField('分类', max_length=50, default='菜品')
    img_url = models.ImageField('封面', upload_to='static/pics/items/')
    sold = models.IntegerField('已购', default=0)
    belonging = models.IntegerField('所属餐厅', default=0)

    def __str__(self):
        return self.name


# 订单模型
class Order(models.Model):
    order_id = models.AutoField(primary_key=True)
    content = models.CharField('点单内容', max_length=200)
    total = models.DecimalField('总价', max_digits=10, decimal_places=2)
    comment = models.CharField('备注', max_length=200)
    guest_id = models.IntegerField('下单人id')
    restaurant_id = models.IntegerField('餐厅id')
    # 订单状态，0为已下单，1为已节单，2为已完成,
    status = models.IntegerField('订单状态', default=0)


class Details(models.Model):
    name = models.CharField('菜名', max_length=20)
    description = models.CharField('说明', max_length=100)
    slogan = models.CharField('标语', max_length=100)
    img_url = models.ImageField('封面', upload_to='static/pics/items/')
    value1 = models.DecimalField('营养价值1', max_digits=10, decimal_places=2)
    value2 = models.DecimalField('营养价值2', max_digits=10, decimal_places=2)
    value3 = models.DecimalField('营养价值3', max_digits=10, decimal_places=2)
    value4 = models.DecimalField('营养价值4', max_digits=10, decimal_places=2)
    value5 = models.DecimalField('营养价值5', max_digits=10, decimal_places=2)
    value6 = models.DecimalField('营养价值6', max_digits=10, decimal_places=2)

    def __str__(self):
        return self.name


class Comment(models.Model):
    text = models.CharField('评论内容', max_length=200)
    user_id = models.IntegerField('用户id')
    order_id = models.IntegerField('订单id')
    user_name = models.CharField('用户名', max_length=32)
    content = models.CharField('订单内容', max_length=200)
    total_price = models.DecimalField('总价', max_digits=10, decimal_places=2)
    comment = models.CharField('备注', max_length=200)
